<!-- My97DatePicker -->
<script language="javascript" type="text/javascript" src="__PUBLIC__/js/My97DatePicker/WdatePicker.js"></script>
<!-- form -->
<script type="text/javascript" src="/Public/js/jquery.form.min.js"></script>
<!-- cxColor -->
<link rel="stylesheet" href="/Public/plugin/cxColor/css/jquery.cxcolor.css">
<script src="/Public/plugin/cxColor/js/jquery.cxcolor.js"></script>

<style type="text/css">
dl{overflow: hidden;zoom: 1;margin-bottom: 20px;font-family: '微软雅黑';font-size: 14px;}
dt{float: left;width: 100px;font-size: 14px;padding: 3px 0 0 0;color: #333;text-align: right;}
dd input[type='text'],select{height: 28px;font-size: 12px;padding: 0 2px;margin: 0 10px 0 10px;box-sizing: border-box;}
dd input[type='text']{width: 200px;}
dd span{height: 28px;padding: 0 2px;margin: 0 10px 0 10px;box-sizing: border-box;}
table tbody tr td{text-align: center;}
.cxcolor{z-index: 9999999;}
</style>

<div class="main_top">
   <a href="{:U(MODULE_NAME.'/Webconf/mobilehome')}" class="<if condition="$step eq false">bg_blue</if>" >BANNER</a>
   <a href="{:U(MODULE_NAME.'/Webconf/mobilehome',array('step'=>'1'))}" class="<if condition="$step eq 1">bg_blue</if>" >专题</a>
   <a href="{:U(MODULE_NAME.'/Webconf/mobilehome',array('step'=>'6'))}" class="<if condition="$step eq 6">bg_blue</if>" >栏目管理</a>
   <!-- <a href="{:U(MODULE_NAME.'/Webconf/mobilehome',array('step'=>'2'))}" class="<if condition="$step eq 2">bg_blue</if>" >免签产品推荐</a> -->
   <!-- <a href="{:U(MODULE_NAME.'/Webconf/mobilehome',array('step'=>'3'))}" class="<if condition="$step eq 3">bg_blue</if>" >精选目的地</a> -->
   <!-- <a href="{:U(MODULE_NAME.'/Webconf/mobilehome',array('step'=>'4'))}" class="<if condition="$step eq 4">bg_blue</if>" >合作伙伴</a> -->
   <a href="{:U(MODULE_NAME.'/Webconf/mobilehome',array('step'=>'5'))}" class="<if condition="$step eq 5">bg_blue</if>" >公司简介</a>
</div>

<div class="form" >
<if condition="$step eq false">
  <div id="banner" class="scrollShow">
    <div class="operate2">
      <ul>
        <!-- <li>更新排序</li> -->
        <li onclick="bannerLayer()"><span class="icon-add01"></span>新增BANNER</li>
      </ul>

      <div class="clear"></div>
    </div>
    <table class="list">
      <thead>
        <tr>
          <th>标题</th>
          <th>图片</th>
          <th>地址</th>
          <th>开始日期</th>
          <th>结束日期</th>
          <th>排序</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      <foreach name='bannerlist' item='v'>
          <tr>
             <td>{$v.title}</td>
             <td>
                <img src="{$v.imagesUrl}" width="220" />
             </td>
             <td><a href="{$v.webUrl}">{$v.webUrl}</a></td>
             <td>
               <if condition="$v['startDate']">
                {$v.startDate}
                <else />
                永久
               </if>
             </td>
             <td>
               <if condition="$v['endDate']">
                {$v.endDate}
                <else />
                永久
               </if>
             </td>
             <td><input type="text" name="sort" value="{$v.sort}" style="width: 20px;" onkeyup="updateSort(this,'{$step}','{$v.id}')"></td>
             <td><if condition="$v.status eq 1"><font class="font-green">启用</font><else /><font class="red">停用</font></if></td>
             <td>
                <if condition="$v.status eq 1">
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','0')">停用</a>
                  <else />
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','1')">启用</a>
                </if>
                &nbsp;&nbsp;
                <a href="javascript:;" onclick="bannerLayer('{$v.id}','{$v.title}','{$v.imagesUrl}','{$v.webUrl}','{$v.startDate}','{$v.endDate}')">编辑</a>&nbsp;&nbsp;
                <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','-1')">删除</a>
             </td>
         </tr>
        </foreach>
   </tbody>
  </table>
  </div>

  <elseif condition="$step eq 1"/>

  <div id="special"  class="scrollShow" >
    <div class="operate2">
      <ul>
        <!-- <li>更新排序</li> -->
        <li onclick="specialLayer()"><span class="icon-add01"></span>新增专题</li>
      </ul>

      <div class="clear"></div>
    </div>
    <table class="list">
      <thead>
        <tr>
          <th>标题</th>
          <th>图片</th>
          <th>地址</th>
          <th>开始日期</th>
          <th>结束日期</th>
          <th>排序</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      <foreach name='speciallist' item='v'>
          <tr>
             <td>{$v.title}</td>
             <td>
                <img src="{$v.imagesUrl}" width="220" />
             </td>
             <td><a href="{$v.webUrl}">{$v.webUrl}</a></td>
             <td>
               <if condition="$v['startDate']">
                {$v.startDate}
                <else />
                永久
               </if>
             </td>
             <td>
               <if condition="$v['endDate']">
                {$v.endDate}
                <else />
                永久
               </if>
             </td>
             <td><input type="text" name="sort" value="{$v.sort}" style="width: 20px;" onkeyup="updateSort(this,'{$step}','{$v.id}')"></td>
             <td><if condition="$v.status eq 1"><font class="font-green">启用</font><else /><font class="red">停用</font></if></td>
             <td>
                <if condition="$v.status eq 1">
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','0')">停用</a>
                  <else />
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','1')">启用</a>
                </if>
                &nbsp;&nbsp;
                <a href="javascript:;" onclick="specialLayer('{$v.id}','{$v.title}','{$v.imagesUrl}','{$v.webUrl}','{$v.startDate}','{$v.endDate}')">编辑</a>&nbsp;&nbsp;
                <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','-1')">删除</a>
             </td>
         </tr>
        </foreach>
   </tbody>
  </table>
  </div>

  <elseif condition="$step eq 2"/>

  <div id="recommend" class="scrollShow" >

    <div class="operate2">
      <ul>
        <!-- <li>更新排序</li> -->
        <li onclick="recommendLayer()"><span class="icon-add01"></span>新增推荐产品</li>
      </ul>

      <div class="clear"></div>
    </div>
    <table class="list">
      <thead>
        <tr>
          <th>标题</th>
          <th>图片</th>
          <th>开始日期</th>
          <th>结束日期</th>
          <th>排序</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      <foreach name='recommendlist' item='v'>
          <tr>
             <td>{$v.title}</td>
             <td>
                <img src="{$v.imagesUrl}" width="220" />
             </td>
             <td>
               <if condition="$v['startDate']">
                {$v.startDate}
                <else />
                永久
               </if>
             </td>
             <td>
               <if condition="$v['endDate']">
                {$v.endDate}
                <else />
                永久
               </if>
             </td>
             <td><input type="text" name="sort" value="{$v.sort}" style="width: 20px;" onkeyup="updateSort(this,'{$step}','{$v.id}')"></td>
             <td><if condition="$v.status eq 1"><font class="font-green">启用</font><else /><font class="red">停用</font></if></td>
             <td>
                <a href="__URL__/Product/details/id/{$v['productID']}">查看</a>&nbsp;&nbsp;
                <if condition="$v.status eq 1">
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','0')">停用</a>
                  <else />
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','1')">启用</a>
                </if>
                &nbsp;&nbsp;
                <a href="javascript:;" onclick="recommendLayer('{$v.id}','{$v.productID}','{$v.title}','{$v.startDate}','{$v.endDate}')">编辑</a>&nbsp;&nbsp;
                <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','-1')">删除</a>
             </td>
         </tr>
        </foreach>
   </tbody>
  </table>

  </div>

  <elseif condition="$step eq 3"/>

  <div id="destination" class="scrollShow" >

    <div class="operate2">
      <ul>
        <!-- <li>更新排序</li> -->
        <li onclick="destinationLayer()"><span class="icon-add01"></span>新增精选目的地</li>
      </ul>

      <div class="clear"></div>
    </div>
    <table class="list">
      <thead>
        <tr>
          <th>名称</th>
          <th>图片</th>
          <th>开始日期</th>
          <th>结束日期</th>
          <th>排序</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      <foreach name='destinationlist' item='v'>
          <tr>
             <td>{$v.title} <span style="display: inline-block; width: 15px; height: 15px; border-radius:50%;  background-color: {$v.bgColor};"></span></td>
             <td>
                <img src="{$v.imagesUrl}" width="220" />
             </td>
             <td>
               <if condition="$v['startDate']">
                {$v.startDate}
                <else />
                永久
               </if>
             </td>
             <td>
               <if condition="$v['endDate']">
                {$v.endDate}
                <else />
                永久
               </if>
             </td>
             <td><input type="text" name="sort" value="{$v.sort}" style="width: 20px;" onkeyup="updateSort(this,'{$step}','{$v.id}')"></td>
             <td><if condition="$v.status eq 1"><font class="font-green">启用</font><else /><font class="red">停用</font></if></td>
             <td>
                <if condition="$v.status eq 1">
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','0')">停用</a>
                  <else />
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','1')">启用</a>
                </if>
                &nbsp;&nbsp;
                <a href="javascript:;" onclick="destinationLayer('{$v.id}','{$v.destinationID}','{$v.bgColor}','{$v.title}','{$v.startDate}','{$v.endDate}')">编辑</a>&nbsp;&nbsp;
                <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','-1')">删除</a>
             </td>
         </tr>
        </foreach>
   </tbody>
  </table>

  </div>

  <elseif condition="$step eq 4"/>

  <div id="partner" class="scrollShow" >

    <div class="operate2">
      <ul>
        <!-- <li>更新排序</li> -->
        <li onclick="partnerLayer()"><span class="icon-add01"></span>新增合作伙伴</li>
      </ul>

      <div class="clear"></div>
    </div>
    <table class="list">
      <thead>
        <tr>
          <th>标题</th>
          <th>图片</th>
          <th>地址</th>
          <th>排序</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      <foreach name='partnerlist' item='v'>
          <tr>
             <td>{$v.title}</td>
             <td>
                <img src="{$v.imagesUrl}" width="220" />
             </td>
             <td><a href="{$v.webUrl}">{$v.webUrl}</a></td>
             <td><input type="text" name="sort" value="{$v.sort}" style="width: 20px;" onkeyup="updateSort(this,'{$step}','{$v.id}')"></td>
             <td><if condition="$v.status eq 1"><font class="font-green">启用</font><else /><font class="red">停用</font></if></td>
             <td>
                <if condition="$v.status eq 1">
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','0')">停用</a>
                  <else />
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','1')">启用</a>
                </if>
                &nbsp;&nbsp;
                <a href="javascript:;" onclick="partnerLayer('{$v.id}','{$v.title}','{$v.imagesUrl}','{$v.webUrl}')">编辑</a>&nbsp;&nbsp;
                <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','-1')">删除</a>
             </td>
         </tr>
        </foreach>
   </tbody>
  </table>

  </div>

  <elseif condition="$step eq 5"/>

  <div id="profile" class="scrollShow" >

    <div class="operate2">
      <ul>
        <!-- <li>更新排序</li> -->
        <li onclick="profileLayer('{:U(MODULE_NAME."/Webconf/profileLayer",array('type'=>'mobile'))}')"><span class="icon-add01"></span>新增公司简介</li>
      </ul>

      <div class="clear"></div>
    </div>
    <table class="list">
      <thead>
        <tr>
          <th>标题</th>
          <th>内容</th>
          <th>排序</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      <foreach name='profilelist' item='v'>
          <tr>
             <td>{$v.title}</td>
             <td>
                {$v.content}
             </td>
             <td><input type="text" name="sort" value="{$v.sort}" style="width: 20px;" onkeyup="updateSort(this,'{$step}','{$v.id}')"></td>
             <td><if condition="$v.status eq 1"><font class="font-green">启用</font><else /><font class="red">停用</font></if></td>
             <td>
                <if condition="$v.status eq 1">
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','0')">停用</a>
                  <else />
                  <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','1')">启用</a>
                </if>
                &nbsp;&nbsp;
                <a href="javascript:;" onclick="profileLayer('{:U(MODULE_NAME."/Webconf/profileLayer",array('type'=>'mobile','id'=>$v['id']))}')">编辑</a>&nbsp;&nbsp;
                <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.title}','-1')">删除</a>
             </td>
         </tr>
        </foreach>
   </tbody>
  </table>

  </div>

  <elseif condition="$step eq 6"/>

  <div id="profile" class="scrollShow" >

    <div class="operate2">
      <ul>
        <!-- <li>更新排序</li> -->
        <li onclick="columnsLayer()"><span class="icon-add01"></span>新增栏目管理</li>
      </ul>

      <div class="clear"></div>
    </div>
    <table class="list">
      <thead>
        <tr>
          <th>名称</th>
          <th>图标</th>
          <th>描述</th>
          <th>链接</th>
          <th>排序</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      <foreach name='columnlist' item='v'>
          <tr>
             <td>{$v.name}</td>
             <td><img src="{$v.imagesUrl}"></td>
             <td>{$v.description}</td>
             <td><a href="{$v.webUrl}" target="_blank">{$v.webUrl}</a></td>
             <td><input type="text" name="sort" value="{$v.sort}" style="width: 20px;" onkeyup="updateSort(this,'{$step}','{$v.id}')"></td>
             <td><if condition="$v.status eq 1"><font class="font-green">启用</font><else /><font class="red">停用</font></if></td>
             <td>
                <a href="javascript:;" onclick="columnsLayer('{$v.id}','{$v.imagesUrl}','{$v.name}','{$v.description}','{$v.webUrl}','{$v.sort}','{$v.status}')">编辑</a>&nbsp;&nbsp;
                <a href="{:U(MODULE_NAME.'/Webconf/mobilehomecolumnstyle',array('id'=>$v['id']))}" >模板</a>&nbsp;&nbsp;
                <!-- <a href="javascript:;" >M模板</a>&nbsp;&nbsp; -->
                <a href="javascript:;" onclick="updateSatus('{$step}','{$v.id}','{$v.name}','-1')">删除</a>
             </td>
         </tr>
        </foreach>
   </tbody>
  </table>

  </div>
  </if>
</div>

<script type="text/javascript">
/**
 * [bannerLayer description]
 * @param  {[type]} bannerID  [description]
 * @param  {[type]} title     [description]
 * @param  {[type]} imagesUrl [description]
 * @param  {[type]} webUrl    [description]
 * @param  {[type]} startTime [description]
 * @param  {[type]} endTime   [description]
 * @return {[type]}           [description]
 */
function  bannerLayer(bannerID,title,imagesUrl,webUrl,startTime,endTime)
{
  if(!bannerID)       bannerID     = '';
  if(!title)          title        = '';
  if(!imagesUrl)      imagesUrl    = '';
  if(!webUrl)         webUrl       = '';
  if(!startTime)      startTime    = '';
  if(!endTime)        endTime      = '';

  var html = '';
      html+='<div id="bannerHtml">';
        html+='<dl>';
          html+='<dt>标题：</dt>';
          html+='<dd><input type="text" name="title" class="inp_default" value="'+title+'" ></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>图片：</dt>';
          html+='<dd>';
            html+='<div style="width: 120px; height: 120px; border: 1px #CCC solid; position: relative; overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer; left: 10px;">';
              html+='<div  class="fileupload" onclick="uploadImgHtml(this,\'Banner\',\'imagesUrl\')" style=" position: absolute;width: 120px;height: auto; right: 0;left: 0;bottom: 0;top: 0;margin: auto;">';
                html+='<img src="'+imagesUrl+'" width="120" height="120">';
                html+='<input type="hidden" name="imagesUrl" value="'+imagesUrl+'">';
              html+='</div>';
           html+='</div>';
          html+='</dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>网站地址</dt>';
          html+='<dd><input type="text" name="webUrl" class="inp_small" value="'+webUrl+'" ></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>开始日期</dt>';
          html+='<dd><input class="input-s" type="text" onClick="WdatePicker()" name="startTime" value="'+startTime+'" readonly /></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>结束日期</dt>';
          html+='<dd><input class="input-s" type="text" onClick="WdatePicker()" name="endTime" value="'+endTime+'" readonly /></dd>';
        html+='</dl>';

      html+='</div>';

    //页面层-自定义
    var Div = layer.open({
        type: 1,
        title: '添加/编辑BANNER',
        area: ['420px', '450px'],
        shift: 0, //从左动画弹出
        content: html,
        btn:['确定','取消'],
        yes: function(index){
          getBanner(bannerID);
        },
        cancel: function(){
          layer.close(Div);
        }
    });
}

/**
 * [addLabelClassAjax description]
 * @param {[type]} id          [description]
 * @param {[type]} name        [description]
 * @param {[type]} description [description]
 */
function  getBanner(bannerID)
{
  var obj       = $('#bannerHtml');

  var title     = obj.find('input[name="title"]').val();
  var imagesUrl = obj.find('input[name="imagesUrl"]').val();
  var webUrl    = obj.find('input[name="webUrl"]').val();
  var startTime = obj.find('input[name="startTime"]').val();
  var endTime   = obj.find('input[name="endTime"]').val();
  var data = {'type' : 'banner','id': bannerID, 'title': title, 'imagesUrl': imagesUrl, 'webUrl': webUrl, 'startTime': startTime ,'endTime': endTime };
  getAjaxPost(data);
/*  $.ajax({
    url: '{:U(MODULE_NAME."/Webconf/mobilehomePost")}',
    type: 'post',
    dataType: 'json',
    data: {'type' : 'banner','id': bannerID, 'title': title, 'imagesUrl': imagesUrl, 'webUrl': webUrl, 'startTime': startTime ,'endTime': endTime },
    success:function (data) {

      if(data.valid == true)
      {
        layer.msg(data.state, {icon: 1});
        location.reload();
      }
      else
      {
        layer.msg(data.state, {icon: 2});
      }
    }
  })*/
}


/**
 * [specialLayer description]
 * @param  {[type]} specialID [description]
 * @param  {[type]} title     [description]
 * @param  {[type]} imagesUrl [description]
 * @param  {[type]} webUrl    [description]
 * @param  {[type]} startTime [description]
 * @param  {[type]} endTime   [description]
 * @return {[type]}           [description]
 */
function  specialLayer(specialID,title,imagesUrl,webUrl,startTime,endTime)
{
  if(!specialID)      specialID = '';
  if(!title)          title     = '';
  if(!imagesUrl)      imagesUrl = '';
  if(!webUrl)         webUrl    = '';
  if(!startTime)      startTime = '';
  if(!endTime)        endTime   = '';

  var html = '';
      html+='<div id="specialHtml">';
        html+='<dl>';
          html+='<dt>标题：</dt>';
          html+='<dd><input type="text" name="title" class="inp_default" value="'+title+'" ></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>图片：</dt>';
          html+='<dd>';
            html+='<div style="width: 120px; height: 120px; border: 1px #CCC solid; position: relative; overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer; left: 10px;">';
              html+='<div  class="fileupload" onclick="uploadImgHtml(this,\'Special\',\'imagesUrl\')"   style=" position: absolute;width: 120px;height: auto; right: 0;left: 0;bottom: 0;top: 0;margin: auto;">';
                html+='<img src="'+imagesUrl+'" width="120" height="120">';
                html+='<input type="hidden" name="imagesUrl" value="'+imagesUrl+'">';
              html+='</div>';
           html+='</div>';
          html+='</dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>网站地址</dt>';
          html+='<dd><input type="text" name="webUrl" class="inp_small" value="'+webUrl+'" ></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>开始日期</dt>';
          html+='<dd><input class="input-s" type="text" onClick="WdatePicker()" name="startTime" value="'+startTime+'" readonly /></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>结束日期</dt>';
          html+='<dd><input class="input-s" type="text" onClick="WdatePicker()" name="endTime" value="'+endTime+'" readonly /></dd>';
        html+='</dl>';

      html+='</div>';

    //页面层-自定义
    var Div = layer.open({
        type: 1,
        title: '添加/编辑专题',
        area: ['420px', '450px'],
        shift: 0, //从左动画弹出
        content: html,
        btn:['确定','取消'],
        yes: function(index){
          getSpecial(specialID);
        },
        cancel: function(){
          layer.close(Div);
        }
    });
}


/**
 * [addLabelClassAjax description]
 * @param {[type]} id          [description]
 * @param {[type]} name        [description]
 * @param {[type]} description [description]
 */
function  getSpecial(specialID)
{
  var obj       = $('#specialHtml');

  var title     = obj.find('input[name="title"]').val();
  var imagesUrl = obj.find('input[name="imagesUrl"]').val();
  var webUrl    = obj.find('input[name="webUrl"]').val();
  var startTime = obj.find('input[name="startTime"]').val();
  var endTime   = obj.find('input[name="endTime"]').val();

  var data = {'type' : 'special','id': specialID, 'title': title, 'imagesUrl': imagesUrl, 'webUrl': webUrl, 'startTime': startTime ,'endTime': endTime };

  getAjaxPost(data);

  /*$.ajax({
    url: '{:U(MODULE_NAME."/Webconf/mobilehomePost")}',
    type: 'post',
    dataType: 'json',
    data: {'type' : 'special','id': bannerID, 'title': title, 'imagesUrl': imagesUrl, 'webUrl': webUrl, 'startTime': startTime ,'endTime': endTime },
    success:function (data) {

      if(data.valid == true)
      {
        layer.msg(data.state, {icon: 1});
        location.reload();
      }
      else
      {
        layer.msg(data.state, {icon: 2});
      }
    }
  })*/
}

/**
 * [recommendLayer description]
 * @param  {[type]} recommendID  [description]
 * @param  {[type]} productID    [description]
 * @param  {[type]} productTitle [description]
 * @param  {[type]} startTime    [description]
 * @param  {[type]} endTime      [description]
 * @return {[type]}              [description]
 */
function  recommendLayer(recommendID,productID,productTitle,startTime,endTime)
{
  if(!recommendID)    recommendID  = '';
  if(!productID)      productID    = '';
  if(!productTitle)   productTitle = '';
  if(!startTime)      startTime    = '';
  if(!endTime)        endTime      = '';

  var html = '';
      html+='<div id="recommendHtml">';
        html+='<dl>';
          html+='<dt>产品编号：</dt>';
          html+='<dd><input type="text" name="productID" class="inp_default" value="'+productID+'" onkeyup="getAjaxBind(this,\'product\')"  ></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>产品标题：</dt>';
          html+='<dd>'+productTitle+'</dd>';
        html+='</dl>';
        html+='<dl>';
        html+='<dl>';
          html+='<dt>开始日期</dt>';
          html+='<dd><input class="input-s" type="text" onClick="WdatePicker()" name="startTime" value="'+startTime+'" readonly /></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>结束日期</dt>';
          html+='<dd><input class="input-s" type="text" onClick="WdatePicker()" name="endTime" value="'+endTime+'" readonly /></dd>';
        html+='</dl>';

      html+='</div>';

    //页面层-自定义
    var Div = layer.open({
        type: 1,
        title: '添加/编辑推荐产品',
        area: ['420px', '320px'],
        shift: 0, //从左动画弹出
        content: html,
        btn:['确定','取消'],
        yes: function(index){
          getRecommend(recommendID);
        },
        cancel: function(){
          layer.close(Div);
        }
    });
}

/**
 * [getRecommend description]
 * @param  {[type]} recommendID [description]
 * @return {[type]}             [description]
 */
function getRecommend(recommendID)
{
  var obj       = $('#recommendHtml');

  var productID     = obj.find('input[name="productID"]').val();
  var startTime = obj.find('input[name="startTime"]').val();
  var endTime   = obj.find('input[name="endTime"]').val();

  var data = {'type' : 'recommend','id': recommendID, 'productID': productID, 'startTime': startTime ,'endTime': endTime };
  getAjaxPost(data);
}

/**
 * [destinationLayer description]
 * @param  {[type]} id              [description]
 * @param  {[type]} destinationID   [description]
 * @param  {[type]} destinationName [description]
 * @param  {[type]} startTime       [description]
 * @param  {[type]} endTime         [description]
 * @return {[type]}                 [description]
 */
function  destinationLayer(id,destinationID,bgColor,destinationName,startTime,endTime)
{
  if(!id)                 id              = '';
  if(!destinationID)      destinationID   = '';
  if(!bgColor)            bgColor         = '';
  if(!destinationName)    destinationName = '';
  if(!startTime)          startTime       = '';
  if(!endTime)            endTime         = '';

  var html = '';
      html+='<div id="destinationHtml">';
        html+='<dl>';
          html+='<dt>目的地编号：</dt>';
          html+='<dd><input type="text" name="destinationID" class="inp_default" value="'+destinationID+'" onkeyup="getAjaxBind(this,\'destination\')" ></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>目的地名称：</dt>';
          html+='<dd>'+destinationName+'</dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>背景颜色：</dt>';
          html+='<dd><input type="text" name="bgColor" class="inp_default" id="element_id"  value="'+bgColor+'"></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>开始日期</dt>';
          html+='<dd><input class="input-s" type="text" onClick="WdatePicker()" name="startTime" value="'+startTime+'" readonly /></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>结束日期</dt>';
          html+='<dd><input class="input-s" type="text" onClick="WdatePicker()" name="endTime" value="'+endTime+'" readonly /></dd>';
        html+='</dl>';

      html+='</div>';

    //页面层-自定义
    var Div = layer.open({
        type: 1,
        title: '添加/编辑精选目的地',
        area: ['420px', '350px'],
        shift: 0, //从左动画弹出
        content: html,
        zIndex : '9',
        btn:['确定','取消'],
        yes: function(index){
          getDestination(id);
        },
        cancel: function(){
          layer.close(Div);
        }
    });

    $('#element_id').cxColor();
}

/**
 * [getRecommend description]
 * @param  {[type]} recommendID [description]
 * @return {[type]}             [description]
 */
function getDestination(id)
{
  var obj       = $('#destinationHtml');

  var destinationID = obj.find('input[name="destinationID"]').val();
  var bgColor       = obj.find('input[name="bgColor"]').val();
  var startTime     = obj.find('input[name="startTime"]').val();
  var endTime       = obj.find('input[name="endTime"]').val();

  var data = {'type' : 'destination','id': id, 'destinationID': destinationID, 'bgColor': bgColor ,'startTime': startTime ,'endTime': endTime };
  getAjaxPost(data);
}

/**
 * [partnerLayer description]
 * @param  {[type]} partnerID [description]
 * @param  {[type]} title     [description]
 * @param  {[type]} imagesUrl [description]
 * @param  {[type]} webUrl    [description]
 * @param  {[type]} startTime [description]
 * @param  {[type]} endTime   [description]
 * @return {[type]}           [description]
 */
function partnerLayer(partnerID,title,imagesUrl,webUrl)
{
  if(!partnerID)      partnerID    = '';
  if(!title)          title        = '';
  if(!imagesUrl)      imagesUrl    = '';
  if(!webUrl)         webUrl       = '';

  var html = '';
      html+='<div id="partnerHtml">';
        html+='<dl>';
          html+='<dt>名称：</dt>';
          html+='<dd><input type="text" name="title" class="inp_default" value="'+title+'" ></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>图片：</dt>';
          html+='<dd>';
            html+='<div style="width: 120px; height: 120px; border: 1px #CCC solid; position: relative; overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer; left: 10px;">';
              html+='<div  class="fileupload" onclick="uploadImgHtml(this,\'Partner\',\'imagesUrl\')"  style=" position: absolute;width: 120px;height: auto; right: 0;left: 0;bottom: 0;top: 0;margin: auto;">';
                html+='<img src="'+imagesUrl+'" width="120" height="120">';
                html+='<input type="hidden" name="imagesUrl" value="'+imagesUrl+'">';
              html+='</div>';
           html+='</div>';
          html+='</dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>网站地址</dt>';
          html+='<dd><input type="text" name="webUrl" class="inp_small" value="'+webUrl+'" ></dd>';
        html+='</dl>';

      html+='</div>';

    //页面层-自定义
    var Div = layer.open({
        type: 1,
        title: '添加/编辑合作伙伴',
        area: ['420px', '350px'],
        shift: 0, //从左动画弹出
        content: html,
        btn:['确定','取消'],
        yes: function(index){
          getPartner(partnerID);
        },
        cancel: function(){
          layer.close(Div);
        }
    });
}

/**
 * [getPartner description]
 * @param  {[type]} partnerID [description]
 * @return {[type]}           [description]
 */
function getPartner(partnerID)
{
  var obj       = $('#partnerHtml');

  var title     = obj.find('input[name="title"]').val();
  var imagesUrl = obj.find('input[name="imagesUrl"]').val();
  var webUrl    = obj.find('input[name="webUrl"]').val();
  var startTime = obj.find('input[name="startTime"]').val();
  var endTime   = obj.find('input[name="endTime"]').val();

  var data = {'type' : 'partner','id': partnerID, 'title': title, 'imagesUrl': imagesUrl, 'webUrl': webUrl, 'startTime': startTime ,'endTime': endTime };
  getAjaxPost(data);
}
/**
 * [getAjaxPost description]
 * @param  {[type]} data [description]
 * @return {[type]}      [description]
 */
function getAjaxPost(data)
{
  $.ajax({
    url: '{:U(MODULE_NAME."/Webconf/mobilehomePost")}',
    type: 'post',
    dataType: 'json',
    data: data,
    success:function (data) {

      if(data.valid == true)
      {
        layer.msg(data.state, {icon: 1});
        location.reload();
      }
      else
      {
        layer.msg(data.state, {icon: 2});
      }
    }
  })
}

/**
 * [profileLayer description]
 * @param  {[type]} profileID [description]
 * @return {[type]}           [description]
 */
function profileLayer(iframeSrc)
{
    layer.open({
          type: 2,
          title: '添加/编辑公司简介',
          area: ['1200px', '680px'],
          fix: false, //不固定
          maxmin: true,
          content:iframeSrc,
      });
}

/**
 * [getAjaxinfo description]
 * @param  {[type]} type [description]
 * @return {[type]}      [description]
 */
function getAjaxBind(obj,type)
{
  var id = $(obj).val();

  $.ajax({
    url: '{:U(MODULE_NAME."/Webconf/getAjaxBind")}',
    type: 'POST',
    dataType: 'json',
    data: {'type': type , 'id': id},
    success:function (data) {

      if(data.valid == true)
      {

        $(obj).parents('dl').next().find('dd').html(data.info.title);
      }
    }
  })
}

/**
 * [columnsLayer description]
 * @param  {[type]} columnID    [description]
 * @param  {[type]} name        [description]
 * @param  {[type]} description [description]
 * @param  {[type]} webUrl      [description]
 * @param  {[type]} sort        [description]
 * @param  {[type]} status      [description]
 * @return {[type]}             [description]
 */
function  columnsLayer(columnID,imagesUrl,name,description,webUrl,sort,status)
{
  if(!columnID)       columnID    = '';
  if(!imagesUrl)      imagesUrl   = '';
  if(!name)           name        = '';
  if(!description)    description = '';
  if(!webUrl)         webUrl      = '';
  if(!sort)           sort        = '';
  if(!status)         status      = 1;

  var html = '';
      html+='<div id="columnsHtml">';
        html+='<dl>';
          html+='<dt>名称：</dt>';
          html+='<dd><input type="text" name="name" class="inp_default" value="'+name+'" ></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>图片：</dt>';
          html+='<dd>';
            html+='<div style="width: 120px; height: 120px; border: 1px #CCC solid; position: relative; overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer; left: 10px;">';
              html+='<div  class="fileupload" onclick="uploadImgHtml(this,\'Special\',\'imagesUrl\')" style=" position: absolute;width: 120px;height: auto; right: 0;left: 0;bottom: 0;top: 0;margin: auto;">';
                html+='<img src="'+imagesUrl+'" width="120" height="120">';
                html+='<input type="hidden" name="imagesUrl" value="'+imagesUrl+'">';
              html+='</div>';
           html+='</div>';
          html+='</dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>描述：</dt>';
          html+='<dd><textarea name="description" rows="6" cols="30" style="resize: none;">'+description+'</textarea></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>链接：</dt>';
          html+='<dd><input type="text" name="webUrl" class="inp_small" value="'+webUrl+'" ></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>排序：</dt>';
          html+='<dd><input type="text" name="sort" class="inp_small" value="'+sort+'" style="width: 60px;"></dd>';
        html+='</dl>';
        html+='<dl>';
          html+='<dt>状态：</dt>';
          html+='<dd>';
           if(status == 1)
          {
            html+='<input class="input-s" type="radio" name="status" value="1" checked />启用';
          }
          else
          {
            html+='<input class="input-s" type="radio" name="status" value="1" />启用';
          }

          if(status == 0)
          {
            html+='<input class="input-s" type="radio" name="status" value="0" checked />停用';
          }
          else
          {
            html+='<input class="input-s" type="radio" name="status" value="0" />停用';
          }
          html+='</dd>';
        html+='</dl>';

      html+='</div>';

    //页面层-自定义
    var Div = layer.open({
        type: 1,
        title: '添加/编辑栏目',
        area: ['500px', '570px'],
        shift: 0, //从左动画弹出
        content: html,
        btn:['确定','取消'],
        yes: function(index){
          getcolumns(columnID);
        },
        cancel: function(){
          layer.close(Div);
        }
    });
}


/**
 * [getcolumns description]
 * @param  {[type]} columnID [description]
 * @return {[type]}          [description]
 */
function  getcolumns(columnID)
{
  var obj    = $('#columnsHtml');
  
  var name        = obj.find('input[name="name"]').val();
  var description = obj.find('textarea[name="description"]').val();
  var imagesUrl   = obj.find('input[name="imagesUrl"]').val();
  var webUrl      = obj.find('input[name="webUrl"]').val();
  var sort        = obj.find('input[name="sort"]').val();
  var status      = obj.find('input[name="status"]:checked').val();

  var data = {'type' : 'columns','id': columnID, 'name': name,'imagesUrl':imagesUrl, 'description': description,'webUrl': webUrl, 'sort': sort ,'status': status };

  getAjaxPost(data);

}


/**
 * [updateSatus description]
 * @param  {[type]} step   [description]
 * @param  {[type]} id     [description]
 * @param  {[type]} name   [description]
 * @param  {[type]} status [description]
 * @return {[type]}        [description]
 */
function updateSatus(step,id,name,status)
{
  var statusName = '';
  switch (status)
  {
    case '1':
      statusName = '启用';
      break;
    case '0':
      statusName = '停用';
      break;
    case '-1':
      statusName = '删除';
      break;
  }
  
  layer.confirm('您确定要'+statusName+'【__'+name+'__】吗？', {
    btn: ['确定','取消'] //按钮
  }, function(){
      $.ajax({
        url: '{:U(MODULE_NAME."/Webconf/mobilehomeUpdateStatus")}',
        type: 'post',
        dataType: 'json',
        data: {'step': step,'id': id,'status': status},
        success:function (data) {

          if(data.valid == true)
          {
            layer.msg(data.state, {icon: 1});
            location.reload();
          }
          else
          {
            layer.msg(data.state, {icon: 2});
          }
        }
      })

  });

}

/**
 * [updateSort description]
 * @param  {[type]} obj  [description]
 * @param  {[type]} step [description]
 * @param  {[type]} id   [description]
 * @return {[type]}      [description]
 */
function updateSort(obj,step,id)
{
  var sort = $(obj).val();
  if(sort.length <= 0)return;
  $.ajax({
    url: '{:U(MODULE_NAME."/Webconf/mobilehomeUpdateSort")}',
    type: 'post',
    dataType: 'json',
    data: {'step': step,'id': id, 'sort': sort},
    success:function (data) {
      if(data.valid == false)
      {
        layer.msg(data.state);
      }
    }
  })

}

/**
 * [uploadImgHtml description]
 * @return {[type]} [description]
 */
function uploadImgHtml(obj,type,thumbImages)
{
  var sizeType = 0;
  if(thumbImages == 'bigPic')sizeType = 1;
  var cityID   = 0;
  if($('select[name="cityID[]"]:first').length > 0 )
  {
    cityID = $('select[name="cityID[]"]:first').val();
  }

  //iframe层-父子操作
  var Div = layer.open({
              type: 2,
              area: ['800px', '400px'],
              content: ['/Home/Public/uploadImages.html?&type='+type+'&sizeType='+sizeType+'&cityID='+cityID,'no'],
              btn: ['确认','取消'], //按钮
              yes: function(index, layero){ //或者使用btn1
                  //按钮【按钮一】的回调

                  var objlayer = $(window.frames['layui-layer-iframe'+index].document);
                  var objlayercurrimg = objlayer.find("#selectImg ul li .curr");
                  if(objlayercurrimg.length <= 0)
                  {
                    var imgUrl = objlayer.find("#dndArea input[name='fileData[]']").val();
                  }
                  else
                  {
                    var imgUrl = objlayercurrimg.parent().find('img').attr('src')
                  }

                  $(obj).empty();
                  $(obj).append('<img src="'+imgUrl+'" width="100%" height="100%"><input type="hidden" name="'+thumbImages+'" class="headerImg" value="'+imgUrl+'">');
                  layer.close(Div);
              },
              cancel: function(index){ //或者使用btn2
                  //按钮【按钮二】的回调
                  layer.close(Div);
              }
          });
}
</script>